"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.serve = void 0;
const path_1 = __importDefault(require("path"));
const koa_1 = __importDefault(require("koa"));
const koa_views_1 = __importDefault(require("koa-views"));
const mark_view_1 = require("./view/mark-view");
const dayjs_1 = __importDefault(require("dayjs"));
const controller_1 = require("./controller");
const config = require('../etc/config');
function serve(config) {
    return __awaiter(this, void 0, void 0, function* () {
        const app = new koa_1.default();
        const { host } = config;
        const { tpl, port } = config;
        const binance = new controller_1.MarkApi(host, '/api/v3');
        const req = { symbol: "ETHBTC" };
        binance.klinesYear(req);
        const cwd = process.cwd();
        console.log(dayjs_1.default().year().valueOf());
        app.use(koa_views_1.default(path_1.default.join(cwd, tpl), {
            extension: 'ejs'
        }));
        const view = yield mark_view_1.createView(config);
        app.use(view);
        app.listen(port, () => {
            console.log(`监听端口${port}`);
        });
    });
}
exports.serve = serve;
